/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game_logic;

import exceptions.InvalidMoveException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Danilo
 */
public abstract class GameControler {
    
    private List<Player> players;
    private Board board;
    
    /**
     * 
     */
    public GameControler(){
        board = new Board();
        getPlayers();
        startGame();
    }
    
    /**
     * 
     */
    public abstract void getPlayers();
    
    /**
     * 
     */
    public void startGame(){
        
        while( ! hasWinner() ){
            
            for( Player player: players ){
                Command command = player.getMove();
                executeCommand( command );
            }
        }
        
    }

    private void executeCommand(Command command) {
        try {
            board.executeCommand(command);
        } catch (InvalidMoveException ex) {
            Logger.getLogger(GameControler.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


    private boolean hasWinner() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

}
